<?php
/**
 * 网站基础设置类
 *
 * PHP Version 5.6
 *
 * @author    guanxu <510104561@qq.com>
 * @time      2017/08/11
 */
namespace Admin\Controller;
use Think\Controller;
use Common\Common\ConstantUtil;
Class WebsiteController extends CommonController {

    public function index() {

        $list = M("website")->where(["status"=>ConstantUtil::GLOBAL_TRUE])->select();
        $this->assign("list",$list);
        $this->display("website/index");

    }

    public function baseAdd() {

        $website= I("post.website");
        if(empty($website)) $this->success("添加成功!");
        foreach($website as $key => $val) {
            M("website")->where(["name"=>$key])->save(["value"=>$val]);
        }
        $this->success("添加成功!");
    }


    public function addView() {
        $this->display('website/add');
    }

    public function add() {

        $data["name"]   = I("post.name");
        $data["value"]   = I("post.value");
        $data["remark"]   = I("post.remark");
        $data["create_time"] = date("Y-m-d H:i:s");
        $result = M("website")->add($data);
        if(empty($result)) {
            $this->success('添加失败!');
        } else {
            $this->success('添加成功!');
        }

    }
}